package cn.cloudtogo.common.atomapi;

import cn.cloudtogo.common.atomapi.token.ApiToken;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

import java.util.LinkedList;
import java.util.List;

/**
 * @author yaolianhua789@gmail.com
 **/
@Data
public class ApiMethodModel {
    private String method;
    private String path;
    @JsonProperty("sub_path")
    private String subPath;
    private String desc;

    private Response response;
    private List<Parameter> parameters = new LinkedList<>();

    private String apiKey;

    @JsonProperty("name")
    private String notes;

    @JsonProperty("authorization")
    private ApiToken token;

    private List<Header> headers = new LinkedList<>();

    @Data
    public static class Parameter {
        private String name;
        private String desc;
        private boolean required;
        private Type type;
        private String example;
    }

    @Data
    public static class Header {
        private String name;
        private String value;
        private boolean required;
        private String example;
    }

    @Data
    public static class Type {
        private String name;
        private String value;

        public Type(String name, String value) {
            this.name = name;
            this.value = value;
        }
    }

    @Data
    public static class Response {
        private int code;
        @JsonProperty("example_value")
        private String example;

        public Response(int code, String example) {
            this.code = code;
            this.example = example;
        }
    }
}
